# 列表有序，字典无序 dict
xiaoming = {  # 键不能重复
    'name': '小明',
    'age': 19,
    'gender': True,
    'height': 1.88
}
print(xiaoming)
dict1 = dict(a=1, b=2)
print(dict1)
# 新增
xiaoming['weigth'] = 68  # 添加新元素
print(xiaoming)
print(xiaoming['name'])  # 获取字典中的元素
xiaoming['age'] = 22  # 修改键值对
print(xiaoming)
print('-------------------')

# 遍历
for i in xiaoming:
    print(i,xiaoming[i])

for k,v in xiaoming.items():
    print(k,v)
print('-------------------')

#方法
xiaoming.pop('gender')  # 删除元素
print(xiaoming)
print(xiaoming.get('name'))
xiaoming.popitem()  # 删除最后一个元素
xiaoming.update({'gender':False})   # 添加一个元素
print(xiaoming)
